package com.situ.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Record implements Serializable{
    /** serialVersionUID*/  
    private static final long serialVersionUID = 116184684L;
    
    private int id;
	private Car car;
	private SpotEnum spotEnum = SpotEnum.ZREOTH;
	private Date startTime = new Date(2000, 1, 1, 0, 0, 0);
	private Date endTime = new Date(2000, 1, 1, 0, 0, 0);;
	private BigDecimal cost = new BigDecimal(0.0);
	
	private static int num = 1;
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	
	/**
	 * <p>Title: describe</p>  
	 * <p>Description: 停车记录字符串</p>  
	 * @author 恩策
	 * @date 2021年7月25日
	 * @return
	 */
	private String describe() {
		return id + "\t" + car + "\t" + spotEnum + "\t" + sdf.format(startTime) + "\t" + sdf.format(endTime) + "\t" + cost;
	}
	
	@Override
	public String toString() {
		return describe();
	}

	// 构造器
	public Record() {
		super();
		this.id = num;
		num++;
	}

	// 进入停车场
	public Record(Car car, SpotEnum spotEnum, Date startTime) {
		this();
		this.car = car;
		this.spotEnum = spotEnum;
		this.startTime = startTime;
	}

	public Record(Car car, SpotEnum spot, Date startTime, Date endTime, BigDecimal cost) {
		this();
		this.car = car;
		this.spotEnum = spot;
		this.startTime = startTime;
		this.endTime = endTime;
		this.cost = cost.setScale(2, RoundingMode.DOWN);
	}

	// getter setter
	public int getId() {
	    return id;
	}
	
	public Car getCar() {
		return car;
	}

	public SpotEnum getSpotEnum() {
		return spotEnum;
	}

	public Date getStartTime() {
		return startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public BigDecimal getCost() {
		return cost;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public void setCost(BigDecimal cost) {
		cost.setScale(2, RoundingMode.DOWN);
		this.cost = cost;
	}

}
